package com.nuanshui.heatedloan.fund.integration.pay.execute.sysexecute;

import com.nuanshui.heatedloan.fund.integration.form.PayForm;
import com.nuanshui.heatedloan.fund.integration.pay.annotation.PayHandlerComponent;
import com.nuanshui.heatedloan.fund.integration.pay.execute.PayConfirmHandler;
import com.nuanshui.heatedloan.fund.model.PayResult;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;

/**
 * 确认同步机制
 * @param 
 * @author guohao
 * @date 2017年1月11日 上午11:53:30
 * @since $
 */
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
@PayHandlerComponent(order=150,value="synchronizedPayConfirmHandler")
public class SynchronizedPayConfirmHandler implements PayConfirmHandler {

	
	private PayConfirmHandler payConfirmHandler;
	@Override
	public PayResult executePaymentConfirm(PayForm payForm) {
		 PayResult payResult = null;
		synchronized (payForm.getOrderNum()) {
			payResult = payConfirmHandler.executePaymentConfirm(payForm);
		}
		return payResult;
	}

	@Override
	public void setPayConfirmHandler(PayConfirmHandler payConfirmHandler) {
		
		this.payConfirmHandler = payConfirmHandler;
		
	}

}
